<!-- 考试-->
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="卷名" prop="courseName">
        <el-input
          v-model="queryParams.courseName"
          placeholder="请输入计划名"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="searchTable()"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery()"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-col :span="24">
      <el-table :data="tableData" border>
        <el-table-column prop="examinationPlanName" label="计划名称" align="center">
        </el-table-column>
        <el-table-column prop="examinationTime" label="执行时间" align="center">
        </el-table-column>
        <el-table-column prop="passScore" label="及格分数" align="center">
        </el-table-column>
        <el-table-column prop="totalScore" label="总分数" align="center">
        </el-table-column>
        <el-table-column prop="referenceNumber" label="参考人数" align="center">
        </el-table-column>
        <el-table-column prop="referenceStatus" label="执行状态" align="center">
          <template slot-scope="scope">
                  <el-tag
                    :type="scope.row.referenceStatus == 0 ? 'danger' : 'success'"
                    disable-transitions
                    >{{ scope.row.referenceStatus == 0 ? "未完成" : "已完成" }}</el-tag
                  >
                </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="200" align="center">
          <template slot-scope="scope">
            <el-button @click="getInfo(scope.row)" type="text" size="small"
              >查看</el-button
            >
            <el-button
              @click="delExaminationPlan(scope.row)"
              type="text"
              size="small"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-col>
    <el-row>
      <el-col>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

    <ExaminationInfo ref="ExaminationInfoRef"></ExaminationInfo>
  </div>
</template>

<script>
import {
  getTeacherExaminationPlanList,
  delExaminationPlan,
} from "@/api/train/index.js";

import ExaminationInfo from './components/examination-info.vue';
export default {
  components:{
    ExaminationInfo
  },
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      tableData: [],
      total: 1,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  computed: {},
  created() {
    this.getList();
  },
  mounted() {},
  methods: {
    // 点击页码及上一页下一页按钮操作
    currentChange(val) {
      this.queryParams.pageNum = val;
      //刷新表格
      this.getList();
    },
     /** 搜索按钮操作 */
     handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //每页展示几条按钮操作
    sizeChange(val) {
      this.queryParams.pageSize = val;
      //刷新表格
      this.getList();
    },
    //获取试卷列表
    getList() {
      getTeacherExaminationPlanList(this.queryParams).then((res) => {
        console.log(res);
        if (res.code === 200) {
          this.tableData = res.rows;
          this.total = res.total;
        }
      });
    },
    //搜索
    searchTable() {
      this.getList();
    },
    openDialog() {
      this.$refs.dialog.show();
    },
    delExaminationPlan(row) {
      delExaminationPlan({
        examinationPlanId: row.examinationPlanId,
      }).then((res) => {
        console.log(res);
        if (res.code === 200) {
          this.getList();
        }
      });
    },

    //详情
    getInfo(row) {
      this.$refs.ExaminationInfoRef.show(row.examinationPlanId);
    },
  },
};
</script>
>

<style>
.box {
  height: calc(100vh - 120px);
  font-size: 14px;
  line-height: 28px;
}

.title {
  font-size: 18px;
  font-weight: 700;
  padding-bottom: 10px;
  padding-top: 20px;
  margin-bottom: 10px;
  border-bottom: #eee 1px dotted;
}

.tags span {
  margin-right: 10px;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: hwb(210 95% 5%);
}

.bg-purple {
  border: 0px solid cornflowerblue;
  height: 200px;
}

.app-container {
  height: 100%;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 60px;
}
</style>
